package com.hzdp.common;

import java.math.BigDecimal;

public class BigDecimalDemo {

	public static void main(String[] args) {
		display(new BigDecimal("-120.00"));
		display(new BigDecimal("1"));
		display(new BigDecimal("61"));
		display(new BigDecimal("6.1"));
		System.out.println("#####################");

		double d = 29.0 * 0.01;
		System.out.println(d);
		System.out.println(d * 100);
		System.out.println((int) (d * 100));
		System.out.println("#####################");

		double f = 29.0 * 0.01;
		System.out.println(f * 100);
		System.out.println((int) (f * 100));

		BigDecimal b = new BigDecimal("29.0").multiply(new BigDecimal("0.01")).multiply(new BigDecimal("100"));
		System.out.println(b);

		BigDecimal b2 = new BigDecimal(29.0).multiply(new BigDecimal(0.01)).multiply(new BigDecimal(100));
		System.out.println(b2);
	}

	private static void display(BigDecimal b) {
		System.out.print(b.signum());
		System.out.print("=>");
		System.out.print(b.scale());
		System.out.print("=>");
		System.out.println(b.stripTrailingZeros().toString());
	}
}
